<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
header('Content-Type:text/html;charset=utf-8');
class Article extends MY_Controller 
{
    protected $code=null;
    public function __construct()
    {
        parent::__construct();
        $this->load->helper('url');
        $this->load->model('article_model');
         $this->load->library('pagination');
    }
    
    /*
    *根据文章分类类型显示不同类别的文章
    *用于ajax调用
    */
    public function showarticle()
    
    {       /*
                id="1">健康
                id="2">癌症
                id="3">糖尿病
            */
        $ppage = $this->input->get('ppage') ? $this->input->get('ppage') : '';//取多少条
        $classId = $this->input->get('thisid') ? $this->input->get('thisid') : 1;//默认显示类别
        echo file_get_contents(DOCUMENT."article_ap/show_article_api?classId={$classId}&ppage={$ppage}");
        
    }
    
    /*
    *显示文章详情页
    */
    public function show_article_content()
    {
        $nounarr = json_decode(file_get_contents(DOCUMENT."step_ao/get_noun_name_api"), true);//专业名词显示
        $dataone = json_decode(file_get_contents(DOCUMENT."step_ao/get_pro_contentone_api"), true);
        $articleID = $this->input->get('ID') ? $this->input->get('ID') : 1;
        $row = json_decode(file_get_contents(DOCUMENT."article_ap/article_content_api?articleID=".$articleID), true);//取的文章信息
        $this->load->view('article/article_content',array('articleInfo'=>$row, 'pro'=>$dataone, 'nounarr'=>$nounarr));
    }
    
    /*
    *对文章发表评论
    */
    public function pubcomment()
    {
       /*
        [articleID] => 95
        [comment_author] => admin2
        [userID] => 8
        [login_ip] => 127.0.0.1
        [user_email] => admin2@qq.com
        [comment] => 
       */
       $commentInfo = json_encode($_POST);
       $identifying = file_get_contents(DOCUMENT."article_ap/insert_comment_api?commentInfo=".$commentInfo);//将评论信息录入
       echo $identifying;
      
    }
    
    /*
    *二级回复入库
    */
    public function towcomment()
    {
        
        $towcommentInfo = json_encode($_POST);
        $iden = file_get_contents(DOCUMENT."article_ap/insert_towcomment_api?towcommentInfo=".$towcommentInfo);
        echo $iden;
        
        
    }
    
    /*
    *删除二级评论
    */
    public function deltowcomment()
    {
        $delID = $this->input->get('delID');
        $iden = file_get_contents(DOCUMENT."article_ap/del_towcomment_api?delID=".$delID);
        echo $iden;
    }
    
     /*
    *删除评论
    */
    public function delparentcomment()
    {
        $delID = $this->input->get('delID');
        $iden = file_get_contents(DOCUMENT."article_ap/del_parentcomment_api?delID=".$delID);
        echo $iden;
    }
    
    /*
    *ajax分页
    */
    public function ajaxpage()
    {
        $classId = $this->input->get('thisid');

        echo file_get_contents(DOCUMENT."article_ap/show_article_api?classId={$classId}");
    }
    
   

}